﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ctrl="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Controls.DiagramSurface"
                    xmlns:vm="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.DiagramSurface"
                    xmlns:dd="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Controls.Attached.DragDrop"
                    xmlns:basevm="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel"
                    xmlns:fluent="clr-namespace:Fluent;assembly=Fluent">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Tum.PDE.ToolFramework.Modeling.Visualization;component/Themes/Default/DiagramLinkAnchorStyle.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <ControlTemplate x:Key="DiagramSurfaceRibbonInsertGroupBox">
        <fluent:InRibbonGallery ItemWidth="200" ItemHeight="24" ResizeMode="Both"
                                      MinItemsInRow="2" MaxItemsInRow="3"
                                      ItemsSource="{Binding ActiveViewModel.InsertableElements, Mode=OneWay}"
                                      Focusable="False" MinWidth="150" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch">
            <fluent:InRibbonGallery.ItemTemplate>
                <DataTemplate>
                    <Button Command="{Binding Path=Command}" CommandParameter="{Binding Path=CommandParameter}" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" Focusable="False">
                        <StackPanel Orientation="Horizontal">
                            <Image x:Name="insertableItemImage" Margin="3,0,3,0"
                                               Stretch="None" Width="16" Height="16" VerticalAlignment="Center" Visibility="Collapsed"/>
                            <TextBlock Margin="3,0,0,0" Text="{Binding Path=Text, Mode=OneWay}" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   ToolTip="{Binding Path=Text, Mode=OneWay}"/>
                        </StackPanel>
                    </Button>
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=HasIcon, Mode=OneTime}" Value="True">
                            <Setter Property="Visibility" TargetName="insertableItemImage" Value="Visible" />
                            <Setter Property="Source" TargetName="insertableItemImage" Value="{Binding Path=IconUrl, Mode=OneTime}" />
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </fluent:InRibbonGallery.ItemTemplate>
        </fluent:InRibbonGallery>
    </ControlTemplate>
    
    <SolidColorBrush Color="#FF00A8FF" x:Key="SelectionBorderBrush"/>
    <SolidColorBrush Color="#FF99CCFF" x:Key="SelectionBrush2"/>

    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="SelectionBrush">
        <GradientStop Color="White"/>
        <GradientStop Color="#FF99CCFF" Offset="1"/>
    </LinearGradientBrush>

    <!-- Connector styles -->
    <Style x:Key="ConnectorItemStyle" TargetType="Path">
        <Setter Property="Fill" Value="{StaticResource SelectionBrush}"/>
        <Setter Property="Stroke" Value="{StaticResource SelectionBorderBrush}"/>
        <Setter Property="StrokeThickness" Value="1"/>
        <Setter Property="StrokeLineJoin" Value="Round"/>
        <Setter Property="Stretch" Value="Fill"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
    </Style>
    <Style x:Key="LeftConnectorItemStyle" TargetType="Path" BasedOn="{StaticResource ConnectorItemStyle}">
        <Setter Property="Width" Value="6"/>
        <Setter Property="Height" Value="11"/>
        <Setter Property="Data" Value="M 0,30 L 30,0 L30,60 Z"/>
        <Setter Property="Cursor" Value="Cross"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
    </Style>
    <Style x:Key="TopConnectorItemStyle" TargetType="Path" BasedOn="{StaticResource ConnectorItemStyle}">
        <Setter Property="Width" Value="11"/>
        <Setter Property="Height" Value="6"/>
        <Setter Property="Data" Value="M 45,0 L 60,40 L 30,40 Z"/>
        <Setter Property="Cursor" Value="Cross"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
    </Style>
    <Style x:Key="RightConnectorItemStyle" TargetType="Path" BasedOn="{StaticResource ConnectorItemStyle}">
        <Setter Property="Width" Value="6"/>
        <Setter Property="Height" Value="11"/>
        <Setter Property="Data" Value="M 30,20 L 30 0 L 60,20 L 30,40 Z"/>
        <Setter Property="Cursor" Value="Cross"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
    </Style>
    <Style x:Key="BottomConnectorItemStyle" TargetType="Path" BasedOn="{StaticResource ConnectorItemStyle}">
        <Setter Property="Width" Value="11"/>
        <Setter Property="Height" Value="6"/>
        <Setter Property="Data" Value="M 0,20 L 30 20 L 60,20 L 30,30 Z"/>
        <Setter Property="Cursor" Value="Cross"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
    </Style>

    <!-- ResizeThumb template -->
    <Style TargetType="{x:Type ctrl:DiagramDesignerItemResizeThumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesignerItemResizeThumb}">
                    <Rectangle Fill="{StaticResource SelectionBrush}" Stroke="{StaticResource SelectionBorderBrush}" StrokeThickness="0.5" Width="7" Height="7" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DragThumb Default Template -->
    <Style TargetType="{x:Type ctrl:DiagramDesignerItemDragThumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesignerItemDragThumb}">
                    <Rectangle Fill="Transparent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Link DragThumb Default Template -->
    <Style TargetType="{x:Type ctrl:DiagramDesignerLinkDragThumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesignerLinkDragThumb}">
                    <Rectangle Fill="{StaticResource SelectionBrush}" Stroke="{StaticResource SelectionBorderBrush}" StrokeThickness="0.5" Width="7" Height="7" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

    <!-- ResizeDecorator Default Template -->
    <ControlTemplate x:Key="ResizeDecoratorTemplate" TargetType="{x:Type Control}">
        <Grid SnapsToDevicePixels="true">
            <ctrl:DiagramDesignerItemResizeThumb x:Name="ResizeThumbN" Height="7" Cursor="SizeNS" Margin="0 -8 0 0"
                     VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
            <ctrl:DiagramDesignerItemResizeThumb x:Name="ResizeThumbW" Width="7" Cursor="SizeWE" Margin="-8 0 0 0"
                     VerticalAlignment="Stretch" HorizontalAlignment="Left"/>
            <ctrl:DiagramDesignerItemResizeThumb x:Name="ResizeThumbE" Width="7" Cursor="SizeWE" Margin="0 0 -8 0"
                     VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
            <ctrl:DiagramDesignerItemResizeThumb x:Name="ResizeThumbS" Height="7" Cursor="SizeNS" Margin="0 0 0 -8"
                     VerticalAlignment="Bottom" HorizontalAlignment="Stretch"/>

            <ctrl:DiagramDesignerItemResizeThumb x:Name="ResizeThumbNW" Width="7" Height="7" Cursor="SizeNWSE" Margin="-8 -8 0 0"
                     VerticalAlignment="Top" HorizontalAlignment="Left"/>
            <ctrl:DiagramDesignerItemResizeThumb Width="7" Height="7" Cursor="SizeNESW" Margin="0 -8 -8 0"
                     VerticalAlignment="Top" x:Name="ResizeThumbNE" HorizontalAlignment="Right"/>
            <ctrl:DiagramDesignerItemResizeThumb Width="7" Height="7" Cursor="SizeNESW" Margin="-8 0 0 -8"
                     VerticalAlignment="Bottom" x:Name="ResizeThumbSW" HorizontalAlignment="Left"/>
            <ctrl:DiagramDesignerItemResizeThumb Width="7" Height="7" Cursor="SizeNWSE" Margin="0 0 -8 -8"
                     VerticalAlignment="Bottom" x:Name="ResizeThumbSE" HorizontalAlignment="Right"/>            
        </Grid>
        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=IsWidthFixed}" Value="True">
                <Setter TargetName="ResizeThumbW" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbE" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbNW" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbNE" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbSW" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbSE" Property="Visibility" Value="Hidden"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsHeightFixed}" Value="True">
                <Setter TargetName="ResizeThumbN" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbS" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbNW" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbNE" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbSW" Property="Visibility" Value="Hidden"/>
                <Setter TargetName="ResizeThumbSE" Property="Visibility" Value="Hidden"/>
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- SelectionDecorator Default Template -->
    <ControlTemplate x:Key="SelectionDecoratorTemplate" TargetType="{x:Type Control}">
        <Grid SnapsToDevicePixels="true">
            <Rectangle Stroke="{StaticResource SelectionBrush2}" StrokeThickness="1" StrokeDashArray="3 6" Margin="-5 -5 -5 -5"
                       VerticalAlignment="Stretch" HorizontalAlignment="Stretch" StrokeDashCap="Square"
                       IsHitTestVisible="False" Focusable="False"/>
        </Grid>
    </ControlTemplate>

    <!-- ConnectorDecoratorTemplate Default Template -->
    <ControlTemplate x:Key="ConnectorDecoratorTemplate" TargetType="{x:Type Control}">
        <Grid>
            <ctrl:DiagramConnector x:Name="Left" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="-20 0 0 0">
                <ctrl:DiagramConnector.Template>
                    <ControlTemplate>
                        <Grid>
                            <Rectangle Fill="Transparent" Margin="-2"/>
                            <Path Style="{StaticResource LeftConnectorItemStyle}"/>
                        </Grid>
                    </ControlTemplate>
                </ctrl:DiagramConnector.Template>
            </ctrl:DiagramConnector>
            <ctrl:DiagramConnector x:Name="Top" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0 -20 0 0">
                <ctrl:DiagramConnector.Template>
                    <ControlTemplate>
                        <Grid>
                            <Rectangle Fill="Transparent" Margin="-2"/>
                            <Path Style="{StaticResource TopConnectorItemStyle}"/>
                        </Grid>
                    </ControlTemplate>
                </ctrl:DiagramConnector.Template>
            </ctrl:DiagramConnector>
            <ctrl:DiagramConnector x:Name="Right" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 0 -20 0">
                <ctrl:DiagramConnector.Template>
                    <ControlTemplate>
                        <Grid>
                            <Rectangle Fill="Transparent" Margin="-2"/>
                            <Path Style="{StaticResource RightConnectorItemStyle}"/>
                        </Grid>
                    </ControlTemplate>
                </ctrl:DiagramConnector.Template>
            </ctrl:DiagramConnector>
            <ctrl:DiagramConnector x:Name="Bottom" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0 0 0 -20">
                <ctrl:DiagramConnector.Template>
                    <ControlTemplate>
                        <Grid>
                            <Rectangle Fill="Transparent" Margin="-2"/>
                            <Path Style="{StaticResource BottomConnectorItemStyle}"/>
                        </Grid>
                    </ControlTemplate>
                </ctrl:DiagramConnector.Template>
            </ctrl:DiagramConnector>
        </Grid>
    </ControlTemplate>

    <!-- DiagramDesignerItem style for elements -->
    <Style TargetType="{x:Type ctrl:DiagramDesignerItem}" x:Key="DiagramDesignerElementsContainerStyle">
        <Setter Property="Canvas.Left" Value="{Binding Path=AbsoluteLeft, Mode=OneWay}"/>
        <Setter Property="Canvas.Top" Value="{Binding Path=AbsoluteTop, Mode=OneWay}"/>
        <Setter Property="Width" Value="{Binding Path=Width, Mode=OneWay}"/>
        <Setter Property="Height" Value="{Binding Path=Height, Mode=OneWay}"/>

        <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
        <Setter Property="MinWidth" Value="5"/>
        <Setter Property="MinHeight" Value="5"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesignerItem}">
                    <Grid>
                        <!-- PART_SelectionDecorator -->
                        <Control x:Name="PART_SelectionDecorator" 
                                 Visibility="Collapsed"
                                 Template="{StaticResource SelectionDecoratorTemplate}"/>
                        
                        <!-- PART_DragThumb -->
                        <Control Margin="-12" x:Name="PART_DragThumbHoster">
                            <Control.Template>
                                <ControlTemplate>
                                    <ctrl:DiagramDesignerItemDragThumb x:Name="PART_DragThumb" Cursor="SizeAll"/>
                                    <ControlTemplate.Triggers>
                                        <DataTrigger Binding="{Binding Path=IsUIFixedPosition}" Value="True">
                                            <Setter TargetName="PART_DragThumb" Property="IsEnabled" Value="False"/>
                                            <Setter TargetName="PART_DragThumb" Property="Cursor" Value="Arrow"/>
                                        </DataTrigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Control.Template>
                        </Control>

                        <!-- PART_ResizeDecorator -->
                        <Control x:Name="PART_ResizeDecorator" 
                                 Visibility="Collapsed"
                                 Template="{StaticResource ResizeDecoratorTemplate}"/>

                        <!-- PART_ConnectorDecorator -->
                        <Control x:Name="PART_ConnectorDecorator"
                                 Visibility="Hidden"
                                 Template="{StaticResource ConnectorDecoratorTemplate}"/>
                        <Grid>
                            <!-- Content -->
                            <ContentPresenter/>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!-- Is selected trigger -->
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True">
                            <Setter TargetName="PART_ResizeDecorator" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="PART_SelectionDecorator" Property="Visibility" Value="Visible"/>
                        </DataTrigger>

                        <!-- Show connector decorator triggers -->
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True"/>
                                <Condition Binding="{Binding Path=TakesPartInRelationship}" Value="True"/>
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="PART_ConnectorDecorator" Property="Visibility" Value="Visible"/>
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DiagramDesignerItem style for links -->
    <Style TargetType="{x:Type ctrl:DiagramDesignerItem}" x:Key="DiagramDesignerLinksContainerStyle">
        <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesignerItem}">
                    <!-- Content -->
                    <ContentPresenter/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DiagramDesignerLinkItem style -->
    <Style x:Key="DefaultConnectionPathStyle" TargetType="Path">
        <Setter Property="StrokeThickness" Value="1"/>
        <Setter Property="Stroke" Value="Black"/>
    </Style>
    <Style TargetType="{x:Type ctrl:DiagramDesignerItemLink}">
        <Style.Resources>
            <Style x:Key="ArrowGridStyle" TargetType="Grid">
                <Setter Property="Width" Value="10"/>
                <Setter Property="Height" Value="10"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TranslateTransform X="-5" Y="-5"/>
                    </Setter.Value>
                </Setter>
            </Style>
        </Style.Resources>
        <Setter Property="MinWidth" Value="5"/>
        <Setter Property="MinHeight" Value="5"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="PathStyle" Value="{StaticResource DefaultConnectionPathStyle}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesignerItemLink}">
                    <Grid>
                        <Canvas>
                            <!-- additional path to make selection easier-->
                            <Path Name="PART_ConnectionPath_Selection" StrokeThickness="3"
                              Stroke="Transparent"
                              StrokeStartLineCap="Round"
                              StrokeEndLineCap="Round"
                              StrokeLineJoin="Round"
                              SnapsToDevicePixels="True"
                              Data="{Binding Path=Geometry}">
                            </Path>

                            <!-- actual path -->
                            <Path Name="PART_ConnectionPath"
                              StrokeStartLineCap="Round"
                              StrokeEndLineCap="Round"
                              StrokeLineJoin="Round"
                              SnapsToDevicePixels="True"
                              Data="{Binding Path=Geometry}"
                              Style="{Binding Path=PathStyle, RelativeSource={RelativeSource TemplatedParent}}">
                            </Path>

                            <!-- source and target endings-->
                            <Grid Style="{StaticResource ArrowGridStyle}"
                             Canvas.Left="{Binding Path=StartEdgePoint.X, Mode=OneWay}" 
                             Canvas.Top="{Binding Path=StartEdgePoint.Y, Mode=OneWay}">
                                <Path Name="PART_StartAnchorPath" Style="{Binding Path=StartArrowStyle, RelativeSource={RelativeSource TemplatedParent}}"/>
                                <Grid.LayoutTransform>
                                    <RotateTransform Angle="{Binding FromAnchorAngle}"/>
                                </Grid.LayoutTransform>
                            </Grid>
                            <Grid Style="{StaticResource ArrowGridStyle}"
                              Canvas.Left="{Binding Path=EndEdgePoint.X, Mode=OneWay}"
                              Canvas.Top="{Binding Path=EndEdgePoint.Y, Mode=OneWay}">
                                <Path Name="PART_EndAnchorPath" Style="{Binding Path=EndArrowStyle, RelativeSource={RelativeSource TemplatedParent}}"/>
                                <Grid.LayoutTransform>
                                    <RotateTransform Angle="{Binding ToAnchorAngle}"/>
                                </Grid.LayoutTransform>
                            </Grid>

                            <!-- drag anchor thumbs-->
                            <ItemsControl x:Name="PART_DragAnchorThumbs" ItemsSource="{Binding Path=EdgePoints, Mode=OneWay}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Canvas>
                                            <ctrl:DiagramDesignerLinkDragThumb x:Name="PART_LinkDragThumb"
                                                                       Cursor="SizeAll" Visibility="Hidden"
                                                                       Canvas.Left="{Binding Path=X, Mode=OneTime}"
                                                                       Canvas.Top="{Binding Path=Y, Mode=OneTime}">
                                                <ctrl:DiagramDesignerLinkDragThumb.RenderTransform>
                                                    <TranslateTransform X="{Binding Path=TranslateX, Mode=OneTime}" 
                                                                        Y="{Binding Path=TranslateY, Mode=OneTime}"/>
                                                </ctrl:DiagramDesignerLinkDragThumb.RenderTransform>
                                            </ctrl:DiagramDesignerLinkDragThumb>
                                        </Canvas>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding Path=EdgePointOperation, Mode=OneTime}" Value="SizeVertical">
                                                <Setter TargetName="PART_LinkDragThumb" Property="Cursor" Value="SizeNS"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Path=EdgePointOperation, Mode=OneTime}" Value="SizeHorizontal">
                                                <Setter TargetName="PART_LinkDragThumb" Property="Cursor" Value="SizeWE"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ctrl:DiagramDesignerItem}},Path=IsSelected}" Value="True">
                                                <Setter TargetName="PART_LinkDragThumb" Property="Visibility" Value="Visible"/>
                                            </DataTrigger>
                                        </DataTemplate.Triggers>                                        
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>

                            <!-- Content -->
                            <ContentPresenter/>
                        </Canvas>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!-- Is selected trigger -->
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ctrl:DiagramDesignerItem}},Path=IsSelected}" Value="True">
                            <Setter TargetName="PART_ConnectionPath_Selection" Property="Stroke" Value="{StaticResource SelectionBrush2}"/>
                        </DataTrigger>

                        <!-- AnchorStyle Trigger -->
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=StartAnchorStyle}" Value="Arrow">
                            <Setter TargetName="PART_StartAnchorPath" Property="Style" Value="{StaticResource DefaultArrowAnchorStyle}"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=StartAnchorStyle}" Value="Diamond">
                            <Setter TargetName="PART_StartAnchorPath" Property="Style" Value="{StaticResource DefaultDiamondAnchorStyle}"/>
                        </DataTrigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=EndAnchorStyle}" Value="Arrow">
                            <Setter TargetName="PART_EndAnchorPath" Property="Style" Value="{StaticResource DefaultArrowAnchorStyle}"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=EndAnchorStyle}" Value="Diamond">
                            <Setter TargetName="PART_EndAnchorPath" Property="Style" Value="{StaticResource DefaultDiamondAnchorStyle}"/>
                        </DataTrigger>

                        <DataTrigger Binding="{Binding Path=IsUIFixedPosition}" Value="True">
                            <Setter TargetName="PART_DragAnchorThumbs" Property="Visibility" Value="Hidden"/>
                        </DataTrigger>
                        
                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ctrl:DiagramDesignerItemsContainerStyleSelector x:Key="DiagramDesignerItemsContainerStyleSelector"
            LinkStyle="{StaticResource DiagramDesignerLinksContainerStyle}"
            ItemStyle="{StaticResource DiagramDesignerElementsContainerStyle}"/>

    <!-- DiagramDesignerItems style -->
    <Style TargetType="{x:Type ctrl:DiagramDesignerItems}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesignerItems}">
                    <ItemsPresenter/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <ctrl:DiagramDesignerCanvas x:Name="DiagramDesignerCanvas" Background="Transparent"
                                                HorizontalAlignment="Stretch" 
                                                VerticalAlignment="Stretch"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyleSelector" Value="{StaticResource DiagramDesignerItemsContainerStyleSelector}"/>
    </Style>

    <!-- DiagramDesigner style -->
    <Style TargetType="{x:Type ctrl:DiagramDesigner}">
        <Setter Property="SelectedItems" Value="{Binding Path=SelectedItemsData, Mode=TwoWay}"/>
        <Setter Property="ClickedPoint" Value="{Binding Path=ClickedPoint, Mode=TwoWay}"/>
        <Setter Property="CreateRelationshipCommand" Value="{Binding Path=CreateRelationshipCommand, Mode=OneWay}"/>
        <Setter Property="dd:DragDrop.IsDropTarget" Value="True"/>
        <Setter Property="dd:DragDrop.DropHandler" Value="{Binding}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:DiagramDesigner}">
                    <Grid>
                        <ctrl:DiagramDesignerItems ActsAsTopMost="True" ItemsSource="{Binding Path=Children, Mode=OneWay}" Background="{TemplateBinding Background}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Default diagram item template -->
    <DataTemplate DataType="{x:Type vm:BaseDiagramItemElementViewModel}">
        <Grid>
            <Border Name="Bd" Margin="0" BorderThickness="1.0" Padding="0" SnapsToDevicePixels="True" Background="#FFF4F2F2" BorderBrush="#FFEAE3E3">
                <Border.Effect>
                    <DropShadowEffect BlurRadius="3" ShadowDepth="2" Color="#FFE0D8D8"/>
                </Border.Effect>
                <TextBlock Margin="3" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Path=DomainElementName}" TextTrimming="CharacterEllipsis"/>
            </Border>
        </Grid>
    </DataTemplate>
    <DataTemplate DataType="{x:Type basevm:BaseModelElementViewModel}">
        <Grid>
            <Border Name="Bd" Margin="0" BorderThickness="1.0" Padding="0" SnapsToDevicePixels="True" Background="#FFF4F2F2" BorderBrush="#FFEAE3E3">
                <Border.Effect>
                    <DropShadowEffect BlurRadius="3" ShadowDepth="2" Color="#FFE0D8D8"/>
                </Border.Effect>
                <TextBlock Margin="3" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Path=DomainElementName}" TextTrimming="CharacterEllipsis"/>
            </Border>
        </Grid>
    </DataTemplate>

    <!-- Default diagram item link template -->
    <DataTemplate DataType="{x:Type vm:BaseDiagramItemLinkViewModel}">
        <ctrl:DiagramDesignerItemLink EndAnchorStyle="None" />
    </DataTemplate>
</ResourceDictionary>
    